'use strict'

const path = require('path')

module.exports = {
  dev: {
    //生成source-map与源码对应 方便调试
    devtool: 'cheap-source-map',
    // 如果部署一级目录(vue-admin.com)就写 / 如果二级目录（http://david.com/vue-admin）就写 /vue-admin
    assetsPublicPath: '/',
    //跨域代理
    proxyTable: {
      '/api': {
        target: 'http://127.0.0.1:9090', //java
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/api': '/api'
        }
      }
    },
    // Paths
    assetsSubDirectory: 'static',
    // 开发 服务器配置
    host: 'localhost', // ip
    port: 3333, //端口
    autoOpenBrowser: true,
    errorOverlay: true,
    notifyOnErrors: false,
    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
    // 是否开启eslint代码检查
    useEslint: false,
    // 是否将eslint错误显示在错误提示中
    showEslintErrorsInOverlay: false,
    // 是否生成cssSourcemap
    cssSourceMap: false
  },

  build: {
    // 生成独立的source-map
    devtool: 'source-map',
    // 如果部署一级目录(vue-admin.com)就写 / 如果二级目录（http://david.com/vue/ /vue/
    assetsPublicPath: '/admin/',
    // 打包输出目录
    assetsRoot: path.resolve(__dirname, '../admin'),
    // Template for index.html
    index: path.resolve(__dirname, '../admin/index.html'),
    assetsSubDirectory: 'static',
    //生产环境不生成sourcemap
    productionSourceMap: false,

    // 是否开启 Gzip
    // 打开前 先安装：
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],

    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report || false,

    // `npm run build:prod --generate_report`
    generateAnalyzerReport: process.env.npm_config_generate_report || false
  }
}
